<%@ Page Title="" Language="C#" MasterPageFile="~/Default.Master" AutoEventWireup="true" CodeBehind="ProdutosBusca.aspx.cs" Inherits="MakeIT.MakeIT.Laundy.Agromotor.Site.Apresentacao.ProdutosBusca" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphHead" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphAreaUtil" runat="server">
    <asp:UpdatePanel ID="upnProduto" runat="server">
        <ContentTemplate>


    <table border="0" cellpadding="0" cellspacing="0" width="750" style="font-size:21px; background-color:White; min-width:750px; max-width:750px; width:750px;">
        <tr>
            <td colspan="3">
                <asp:Image ID="Image1" runat="server" ImageUrl="~/App_Themes/Padrao/Imagens/site/loja_agromotor4p.png" />
                <asp:Image ID="Image2" runat="server" ImageUrl="~/App_Themes/Padrao/Imagens/site/loja_agromotor5.png" />
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <asp:Image ID="Image3" runat="server" ImageUrl="~/App_Themes/Padrao/Imagens/site/buscabox_topo.png" />
            </td>
        </tr>
        <tr>
            <td style="background: url( 'App_Themes/Padrao/Imagens/site/buscabox_b.png' ) repeat-y 0px 0px; width: 8px;"></td>
            <td align="left">
                <asp:Label ID="lblAvisoCotacao" runat="server" Text="" Visible="false" ForeColor="Red"></asp:Label>&nbsp;
                <asp:Button ID="btFinalizarCotacao" runat="server" Text="Alterar/Finalizar cota&ccedil;&atilde;o" OnClick="btFinalizarCotacao_Click" Visible="false"/>
            </td>
            <td style="background:url( 'App_Themes/Padrao/imagens/site/buscabox_b.png' ) repeat-y -10px 0px; width: 6px;"></td>
        </tr>
        <tr>
            <td style="background: url( 'App_Themes/Padrao/Imagens/site/buscabox_b.png' ) repeat-y 0px 0px; width: 8px;"></td>
            <td align="center" style="width:736px;">
                <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
                    <asp:View ID="ViewBusca" runat="server">
                        <table border="0" cellspacing="5">
                            <tr>
                                <td align="right">
                                    Buscar pe&ccedil;a por nome / descri&ccedil;&atilde;o
                                </td>
                                <td align="left">
                                    <asp:TextBox ID="txtBuscaNome" Width="310" Height="40" Font-Size="21px" runat="server" BorderStyle="Solid" BorderWidth="1"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    Buscar pe&ccedil;a pelo c&oacute;digo do fabricante
                                </td>
                                <td align="left">
                                    <asp:TextBox ID="txtBuscaCodigo" Width="310" Height="40" Font-Size="21px" runat="server" BorderStyle="Solid" BorderWidth="1" BorderColor="#c0c0c0"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td align="left">
                                    <asp:Button ID="btnBusca" runat="server" Text="BUSCAR PE&Ccedil;AS" OnClick="btnBusca_Click" />
                                </td>
                            </tr>
                        </table>
                    </asp:View>
                    <asp:View ID="ViewResultadoBusca" runat="server">
                        <table width="100%" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td align="left">
                                    Sua consulta encontrou <asp:Literal ID="lblQtdBusca" runat="server"></asp:Literal> &iacute;tens em estoque
                                    <asp:Button ID="btNovaPesquisa" runat="server" Text="Nova Pesquisa" OnClick="btNovaPesquisa_Click" />
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td align="center">
                    <div style="width:100%; overflow:auto; font-size:14px;">
                                    <asp:GridView ID="grvResultadoBusca" runat="server" AutoGenerateColumns="False"
                                         RowStyle-HorizontalAlign="Left"
                                         PageSize="20" PagerSettings-Mode="NumericFirstLast" AllowPaging="true"
                                         GridLines="None"
                                         HeaderStyle-HorizontalAlign="Left" HeaderStyle-Font-Size="15px"
                                         OnPageIndexChanging="grvResultadoBusca_PageIndexChanging">
                                        <Columns>
                                            <asp:BoundField DataField="codigo" HeaderText="C&oacute;digo" ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1" HeaderStyle-HorizontalAlign="Left"/>
                                            <asp:BoundField DataField="peca" HeaderText="Descri&ccedil;&atilde;o" ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1"  HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1" HeaderStyle-HorizontalAlign="Left"/>
                                            <asp:TemplateField ShowHeader="false">
                                                <ItemTemplate>
                                                    &nbsp;
                                                </ItemTemplate>
                                                <ItemStyle BorderStyle="None" Width="20px" />
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Detalhes" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1" HeaderStyle-HorizontalAlign="Left">
                                                <ItemTemplate>
                                                    <asp:ImageButton ID="ibDetalhes" runat="server" Visible='<%#(Eval("imagemNome")!=null?true:false) %>' 
                                                      OnClick="lnkDetalhes_Click" CommandArgument='<%#Eval("idPeca")%>' ImageUrl="~/App_Themes/Padrao/Imagens/site/camera.png"/>
                                                </ItemTemplate>
                                                <ItemStyle BorderStyle="Solid" BorderWidth="1" Font-Size="11px" HorizontalAlign="Center"/>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Loja" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1" HeaderStyle-HorizontalAlign="Left">
                                                <ItemTemplate>
                                                    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="http://loja.agromotor.com.br" Target="lojavirtual" Visible='<%#(Eval("loja")!=null?true:false) %>'><%# Eval("loja") != null ? (bool)Eval("loja") ? "DISPON&Iacute;VEL TAMB&Eacute;M EM<br>NOSSA LOJA VIRTUAL" : "" : ""%></asp:HyperLink>
                                                </ItemTemplate>
                                                <ItemStyle BorderStyle="Solid" BorderWidth="1" Font-Size="8px" HorizontalAlign="Center" />
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Cota&ccedil;&atilde;o" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1" HeaderStyle-HorizontalAlign="Left">
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lbOrcamento" Visible='<%#(Eval("orcamento")!=null?true:false) %>' runat="server" OnClick="lbOrcamento_Click" CommandArgument='<%#Eval("idPeca")%>'>SOLICITAR COTA&Ccedil;AO</asp:LinkButton>
                                                </ItemTemplate>
                                                <ItemStyle BorderStyle="Solid" BorderWidth="1" Font-Size="8px" HorizontalAlign="Center" />
                                            </asp:TemplateField>
                                        </Columns>
                                        <PagerStyle Font-Bold="true" Font-Size="21px" HorizontalAlign="Right" ForeColor="#202020"  />
                                        <RowStyle Height="27px" VerticalAlign="Middle" />
                                        <HeaderStyle Height="35px" VerticalAlign="Middle" />
                                    </asp:GridView>
                    </div>
                                </td>
                            </tr>
                        </table>
                    </asp:View>
                    <asp:View ID="ViewDetalhePeca" runat="server">
                        <table width="100%" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td rowspan="3">
                                    <asp:Image ID="imgPeca" runat="server" />
                                </td>
                                <td valign="top">
                                    <table border="1" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td align="left" valign="middle" style="min-width:150px; height:35px; Font-Size:15px;">
                                                <b>C&oacute;digo</b>
                                            </td>
                                            <td align="left" valign="middle" style="min-width:200px; height:35px; Font-Size:15px;">
                                                <b>Descri&ccedil;&atilde;o</b>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" valign="middle" style="height:35px; Font-Size:14px;">
                                                <asp:Label ID="lblIdPeca" runat="server" Text="Label"></asp:Label>
                                            </td>
                                            <td align="left" valign="middle" style="height:35px; Font-Size:14px;">
                                                <asp:Label ID="lblPeca" runat="server" Text="Label"></asp:Label>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td valign="bottom">
                                    <table border="1" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td align="left" valign="middle" style="min-width:150px; height:35px; Font-Size:15px;">
                                                <b>Loja</b>
                                            </td>
                                            <td align="left" valign="middle" style="min-width:200px; height:35px; Font-Size:15px;">
                                                <b>Cota&ccedil;&atilde;o</b>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" valign="middle" style="height:35px; Font-Size:14px;">
                                                <asp:HyperLink ID="hlLojaVirtual" Font-Size="10px" runat="server" NavigateUrl="http://loja.agromotor.com.br" Target="lojavirtual" Text="DISPON&Iacute;VEL TAMB&Eacute;M EM<Br>NOSSA LOJA VIRTUAL"></asp:HyperLink>
                                            </td>
                                            <td align="left" valign="middle" style="height:35px; Font-Size:14px;">
                                                <asp:LinkButton ID="lbOrcamento" runat="server" OnClick="lbOrcamento_Click">SOLICITAR COTA&Ccedil;AO</asp:LinkButton>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    <asp:Button ID="btVoltarResultadoBusca" runat="server" Text="Voltar" OnClick="btVoltarResultadoBusca_Click"/>
                                </td>
                            </tr>
                        </table>
                    </asp:View>
                    <asp:View ID="ViewCotacao" runat="server">
                        <table width="100%" border="0" cellpadding="0" cellspacing="0">
                            <tr style="border-bottom:dashed 1 #13294E;">
                                <td align="left" colspan="2" style="color:#13294E;">
                                    Por favor informe seus dados para contato:
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    Nome:
                                </td>
                                <td align="left">
                                    <asp:TextBox ID="txtCadNome" MaxLength="100" Width="280" ForeColor="DarkBlue" Font-Bold="true" runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ControlToValidate="txtCadNome" 
                                       ErrorMessage="Preenchimento obrigat&oacute;rio." ID="rfvtxtCadNome" Display="None"
                                       runat="server" ValidationGroup="Enviar" ></asp:RequiredFieldValidator>
                                    <asp:ValidatorCalloutExtender ID="vcetxtCadNome" runat="server" TargetControlID="rfvtxtCadNome"></asp:ValidatorCalloutExtender>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    Email:
                                </td>
                                <td align="left">
                                    <asp:TextBox ID="txtCadEmail" MaxLength="100" Width="280" ForeColor="DarkBlue" Font-Bold="true" runat="server"></asp:TextBox>
                                    <asp:RegularExpressionValidator ID="revtxtCadEmail" runat="server" ControlToValidate="txtCadEmail" 
                                    ErrorMessage="email incorreto" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                     ValidationGroup="Enviar" Display="None" ></asp:RegularExpressionValidator>
                                    <asp:ValidatorCalloutExtender ID="vcerevtxtCadEmail" runat="server" TargetControlID="revtxtCadEmail"></asp:ValidatorCalloutExtender>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    Telefone:
                                </td>
                                <td align="left">
                                    <asp:TextBox ID="txtCadFone" MaxLength="20" Width="130" ForeColor="DarkBlue" Font-Bold="true" runat="server"></asp:TextBox>
                                    <asp:MaskedEditExtender ID="meeFONEtxtCadFone" runat="server" 
                                        CultureAMPMPlaceholder="" CultureCurrencySymbolPlaceholder="" 
                                        CultureDateFormat="" CultureDatePlaceholder="" CultureDecimalPlaceholder="" 
                                        CultureThousandsPlaceholder="" CultureTimePlaceholder="" Enabled="True" 
                                        Mask="(99)9999-9999" TargetControlID="txtCadFone" 
                                        ClearMaskOnLostFocus="false">
                                    </asp:MaskedEditExtender>
                                </td>
                            </tr>
                            <tr>
                                <td align="left" colspan="2" style="color:#13294E; border-bottom:dashed 1 #13294E;">
                                   <hr />
                                   &Iacute;tens na cota&ccedil;&atilde;o:
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <asp:GridView ID="GridViewItens" runat="server" AutoGenerateColumns="False" 
                                        CellPadding="2" ForeColor="#333333" 
                                        GridLines="None" CellSpacing="2" Enabled="true">
                                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" Font-Size="Small"/>
                                        <Columns>
                                            <asp:TemplateField>
                                                <ItemTemplate>
                                                    <asp:Label ID="lblItem" runat="server" Text='<%# Container.DataItemIndex+1 %>'></asp:Label>
                                                </ItemTemplate>
                                                <HeaderTemplate>Item</HeaderTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="codigo" HeaderText="C&oacute;digo"/>
                                            <asp:BoundField DataField="peca" HeaderText="Descri&ccedil;&atilde;o"/>
                                            <asp:TemplateField>
                                                <ItemTemplate>
                                                    <asp:HiddenField ID="hfIdPeca" runat="server" Value='<%# Eval("idPeca") %>' />
                                                    <asp:TextBox ID="tbQtd" runat="server" Columns="10" MaxLength="9" onkeypress="onlyNum();" onblur="validaDecimal(this.value,9,0);" 
                                                        Text='<%# DataBinder.Eval(Container.DataItem, "qtdCotacao").ToString()%>'> </asp:TextBox>
                                                    <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="tbQtd" 
                                                        ErrorMessage="Favor informar uma quantidade maior que zero, obrigado." Display="None"
                                                        MinimumValue="1" MaximumValue="999999999" Type="Integer" ValidationGroup="salvar"></asp:RangeValidator>
                                                    <asp:RequiredFieldValidator ControlToValidate="tbQtd" 
                                                       ErrorMessage="Favor informar a quantidade, obrigado." ID="rfvTbQtd" Display="None"
                                                       runat="server" Text="text" ToolTip="tooltip" ValidationGroup="salvar" ></asp:RequiredFieldValidator>
                                                    <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" TargetControlID="rfvTbQtd"></asp:ValidatorCalloutExtender>
                                                    <asp:ValidatorCalloutExtender ID="revDigit1Ext" runat="server" TargetControlID="RangeValidator1"></asp:ValidatorCalloutExtender>
                                                </ItemTemplate>
                                                <HeaderTemplate>Quantidade</HeaderTemplate>
                                            </asp:TemplateField>
                                             <asp:TemplateField>
                                                <ItemTemplate>
                                                    <asp:ImageButton ID="imgbRemove" runat="server" ImageUrl="~/App_Themes/Padrao/Imagens/site/shopping_cart_remove.png" 
                                                    ToolTip="Remove esta peça da lista" OnClick="imgbRemove_Click" CommandArgument='<%#Eval("IdPeca")%>'/>
                                                    <asp:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" ConfirmText="Confirma a exclusão deste item do carrinho?" Enabled="True" TargetControlID="imgbRemove">
                                                    </asp:ConfirmButtonExtender>
                                                </ItemTemplate>
                                                <HeaderTemplate>Remover</HeaderTemplate>
                                             </asp:TemplateField>
                                           
                                        </Columns>
                                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" Font-Size="Small" />
                                        <EditRowStyle BackColor="#999999" />
                                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                    </asp:GridView>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                   <hr />
                                    <asp:Button ID="btEnviaEmail" runat="server" Text="Finalizar" ValidationGroup="Enviar" OnClick="btEnviaEmail_Click" />&nbsp;
                                    <asp:Button ID="btVoltar" runat="server" Text="Voltar" OnClick="btVoltar_Click"/>
                                </td>
                            </tr>
                        </table>
                        
                    </asp:View>
                    <asp:View ID="ViewResultadoBuscaCategoria" runat="server">
                        <table width="100%" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td align="left">
                                    <b>Sua busca foi encontrada em v&aacute;rias categorias.</b><br />
                                    <br />
                                    Clique em uma das categorias abaixo para refinar sua busca:
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td align="center" style="padding-left:20px;">
                                    <asp:Repeater ID="RepeaterCategorias" runat="server">
                                        <ItemTemplate>
                                            <asp:Button ID="btCategoria" Width="300" Height="40" runat="server" Text='<%#Eval("Categoria")%>' 
                                                OnClick="btCategoria_Click" CommandArgument='<%#Eval("IdCategoria")%>' /><br />
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </td>
                            </tr>
                        </table>
                    </asp:View>
                </asp:MultiView>
            </td>
            <td style="background:url( 'App_Themes/Padrao/Imagens/site/buscabox_b.png' ) repeat-y -10px 0px; width: 6px;"></td>
        </tr>
        <tr><td style="background: url( 'App_Themes/Padrao/imagens/site/buscabox.png' ) no-repeat 0px -24px; width: 8px; height: 21px;"></td>
            <td style="background: url( 'App_Themes/Padrao/imagens/site/buscabox.png' ) repeat-x 0px 0px; height: 21px;"></td>
            <td style="background: url( 'App_Themes/Padrao/imagens/site/buscabox.png' ) no-repeat -10px -24px; width: 6px; height: 21px;"></td>
        </tr>
        <tr>
            <td colspan="3">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <asp:ImageMap ID="ImageMap1" runat="server" ImageUrl="~/App_Themes/Padrao/Imagens/site/buscaguy.png" >
                    <asp:RectangleHotSpot Top="38" Left="494" Bottom="73" Right="696" PostBackValue="39" Target="_blank" NavigateUrl="~/DownCatalogo.aspx?orderBy=desc" />
                    <asp:RectangleHotSpot Top="115" Left="494" Bottom="150" Right="696" PostBackValue="39" Target="_blank" NavigateUrl="~/DownCatalogo.aspx?orderBy=codigo" /> 
                </asp:ImageMap>
            </td>
        </tr>
    </table>

        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
